package com.osc.exam.service.impl;

import com.osc.exam.dao.PracticeDao;
import com.osc.exam.entity.domain.Practice;
import com.osc.exam.service.PracticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class PracticeServiceImpl implements PracticeService {

    @Autowired
    private PracticeDao practiceDao;


    @Override
    @Transactional(rollbackFor=Exception.class)
    public boolean insert(Practice practice) {
        practice.setCreateTime(new Date());
        practice.setUpdateTime(new Date());
        return practiceDao.insert(practice)>0;
    }

    @Override
    public List<Practice> getPracById(int id) {
        return practiceDao.getPracById(id);
    }
}
